package com.briup;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;
//查询所有的学生
public class GetAll {
  public static void main(String[] args) {
    String resource = "mybatis-config.xml";
      SqlSession sqlSession = null;
      try (InputStream resourceAsStream = Resources.getResourceAsStream(resource)) {
          SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsStream);
          sqlSession   = build.openSession();
          StuMapper mapper = sqlSession.getMapper(StuMapper.class);
          List<Student> getall = mapper.getall();
          for (Student s : getall ) {
        System.out.println(s);
          }
      }catch (Exception e){
          e.printStackTrace();
      }
  }
}
